/*******************
4位的超前进位加法器 CLA
********************/

module CLA_4(
    input   [4-1:0]         a           ,
    input   [4-1:0]         b           ,
    input                   c0          ,

    output  [5-1:0]         result      
    
);

wire    [4-1:0]     pi          ;
wire    [4-1:0]     gi          ;

wire                c1          ;
wire                c2          ;
wire                c3          ;
wire                c4          ;

wire    [4-1:0]     si          ;

assign pi = a ^ b               ;
assign gi = a & b               ;

assign c1 = gi[0] + (pi[0] & c0)   ;
assign c2 = gi[1] + (pi[1] & gi[0]) + (pi[1] & pi[0] & c0) ;
assign c3 = gi[2] + (pi[2] & gi[1]) + (pi[2] & pi[1] & gi[0]) + (pi[2] & pi[1] & pi[0] & c0) ;
assign c4 = gi[3] + (pi[3] & gi[2]) + (pi[3] & pi[2] & gi[1]) + (pi[3] & pi[2] & pi[1] & gi[0]) + (pi[3] & pi[2] & pi[1] & pi[0] & c0) ;

assign si = pi ^ {c3, c2, c1, c0};

assign result = {c4, si} ;
    
    
endmodule

































